package utils

import (
	"fmt"
	"os"

	"gopkg.in/yaml.v2"
)

type Config struct {
	UseAOF        bool   `yaml:"use_aof"`
	UseRDB        bool   `yaml:"use_rdb"`
	AOFPath       string `yaml:"aof_path"`
	AOFStrategy   string `yaml:"aof_strategy"`
	RDBPath       string `yaml:"rdb_path"`
	ServerPort    string `yaml:"server_port"`
	ServerAddress string `yaml:"server_address"`
}

var Cnf *Config = &Config{}

func init() {
	var p string
	if p = os.Getenv("CONFIG_PATH"); p == "" {
		fmt.Println("config file not found")
		os.Exit(1)
	}
	content, _ := os.ReadFile(p)
	yaml.Unmarshal(content, &Cnf)
	fmt.Println(Cnf)
}
